<?php

namespace App\Http\Controllers\Customer;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;

class HomeController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('checkCustomer');
    }
    
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $treeData = getCategoryTreeData();


        $newGoods = DB::table('goods_master as gm')->select(DB::raw('gm.goods_id,gm.goods_name,concat(gp.image_url,gp.file_name) as img_url'))->leftJoin('goods_picture as gp','gm.goods_id','=','gp.goods_id')->get();
        return view('customer/home',[
            'treeData'=>$treeData,
            'newGoods' => $newGoods,
        ]);
    }
}
